const mongoose = require("mongoose")
// const Schema = mongoose.Schema
// const model = mongoose.model
const bcrypt = require("bcryptjs")
const { Schema, model } = mongoose
const UserSchema = new Schema({
    username: {
        type: String,
        required: [true, "username 是必须的"],
    },
    password: {
        type: String,
        required: [true, "password 是必须的"],
        set(val) {
            return bcrypt.hashSync(val, 10)
        }
    },
    peoplelikes: [{ type: mongoose.SchemaTypes.ObjectId, ref: 'User' }],
    musiclikes: [{ type: mongoose.SchemaTypes.ObjectId, ref: 'Music' }],
})

const User = model("User", UserSchema)
module.exports = User